package grpc.client;

import grpc.proto.MyRequest;
import grpc.proto.MyResponse;
import grpc.proto.StudentServiceGrpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

/**
 * @author RJA
 * @version V1.0
 * @Title: grpc.client.demo_1
 * @Description:
 * @date 2019/8/23 17:06
 */
public class GrpcClient {
    public static void main(String[] args) {
        ManagedChannel managedChannel = ManagedChannelBuilder.forAddress("localhost",8899)
                .usePlaintext().build();
        StudentServiceGrpc.StudentServiceBlockingStub blockingStub = new StudentServiceGrpc
                .StudentServiceBlockingStub(managedChannel);
            MyResponse response = blockingStub.getRealnameByUsername(MyRequest.newBuilder().setUsername("张三").build());
            System.out.println(response.getRealname());
    }
}
